#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
using namespace std;
#include"String.h"

void TestString1()
{
    mySTLString::string s1("what do you want for me");
    cout << s1.c_str() << endl;

    s1[0] = 'a';
    cout << s1.c_str() << endl;

    for (size_t i = 0; i < s1.size(); ++i)
    {
        cout << s1[i] << " ";
    }
    cout << endl;
}

void TestString2()
{
    mySTLString::string s1("what do you want for me");
    mySTLString::string s2(s1);
    cout << s1.c_str() << endl;
    cout << s2.c_str() << endl;
}

void TestString3()
{
    mySTLString::string s1("what do you want for me");
    mySTLString::string s2(s1);
    mySTLString::string s3("Oh yes baby!");

    s1 = s3;
    cout << s1.c_str() << endl;
    cout << s2.c_str() << endl;
    cout << s3.c_str() << endl;

    s1 = s1;
    cout << s1.c_str() << endl;
    cout << s2.c_str() << endl;
    cout << s3.c_str() << endl;
}

void TestString4()
{
    mySTLString::string s1("Oh yes baby!");
    s1.push_back('2');
    s1.push_back('2');
    s1.push_back('2');
    cout << s1.c_str() << endl;

    s1 += '~';
    s1 += '~';
    s1 += '~';
    cout << s1.c_str() << endl;
    
    s1 += "enenenen";
    cout << s1.c_str() << endl;

    mySTLString::string s2("what do you want for me");
    s2.reserve(80);
    s2.resize(12, 'x');
    s2.resize(10);
    s1 < s2;
}

void TestString5()
{
    mySTLString::string s1("hello world!");
    s1.insert(6, "yes");
    cout << s1.c_str() << endl;

    s1.insert(2, "x");
    cout << s1.c_str() << endl;

    s1.erase(0, 6);
    cout << s1.c_str() << endl;

    s1.erase(2);
    cout << s1.c_str() << endl;
}

int main()
{
    //TestString1();
    //TestString2();
    //TestString3();
    //TestString4();
    TestString5();
    return 0;
}